package com.inmarry.util;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import java.io.*;



/**
 * 项目:    www.in-marry.com
 * 文件:    src/util/DBConnection.java
 *
 * 从数据库连接池取得数据库连接
 *
 * @author: Mike.G <hylinux@gmail.com>
 * @version:    $Id:$
 */
public final class DBConnection implements Serializable {

    private static final SqlMapClient sqlMap;

    static {
        try {
            String resource = "SqlMapConfig.xml";
            Reader reader = Resources.getResourceAsReader(resource);
            sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
        } catch ( Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException("Error initializing MyAppSqlConfig class" + ex);
        }
    }

    public static SqlMapClient getSqlMapInstance() {
        return sqlMap;
    }

}

